<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>文章黑白配色切换</title>

    <style>
        :root {
            --background: white;
            --text: black;
        }

        body {
            height: 100vh;
            display: -webkit-box;
            display: flex;
            -webkit-box-align: center;
            align-items: center;
            -webkit-box-pack: center;
            justify-content: center;background-color: #fff5db;
        }

        .browser {
            max-width: 750px;
            width: 95%;
            border-radius: 12px;
            max-height: 650px;
            position: relative;
            overflow: hidden;
            box-shadow: inset 0 0 1px 1px black;
        }

        .browser__header {
            padding: 15px;
            position: relative;
        }
        .browser__header::after {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 1px;
            background: black;
            content: "";
        }

        .browser__header i {
            display: inline-block;
            vertical-align: middle;
            width: 10px;
            height: 10px;
            border-radius: 100px;
            margin-right: 5px;
            border: 1px solid black;
        }
        .browser__header i:nth-child(1) {
            background: #E85D75;
        }
        .browser__header i:nth-child(2) {
            background: #EEC643;
        }
        .browser__header i:nth-child(3) {
            background: #79B791;
        }

        .browser__content {
            padding: 20px;
            padding-bottom: 5vh;
        }

        .browser h1,
        .browser p {
            color: var(--text);
            -webkit-transition: color 200ms linear 100ms;
            transition: color 200ms linear 100ms;
        }

        .browser__content p {
            line-height: 1.5;
        }

        .toggle {
            position: absolute;
            top: 14px;
            right: 15px;
        }

        .toggle label {
            position: relative;
            display: block;
            width: 50px;
            height: 22px;
            background: #fff;
            border: 1px solid var(--text);
            border-radius: 100px;
            cursor: pointer;
        }
        .toggle label::before {
            position: absolute;
            width: 900px;
            height: 900px;
            background: var(--background);
            z-index: 10;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            border-radius: 100%;
            opacity: 1;
            -webkit-transform: translate3d(-47%, 0, 0) scale(0.1);
            transform: translate3d(-47%, 0, 0) scale(0.1);
            -webkit-transition: background 300ms ease-in-out 200ms, opacity 350ms ease-in-out 200ms, -webkit-transform 400ms ease-in-out;
            transition: background 300ms ease-in-out 200ms, opacity 350ms ease-in-out 200ms, -webkit-transform 400ms ease-in-out;
            transition: background 300ms ease-in-out 200ms, opacity 350ms ease-in-out 200ms, transform 400ms ease-in-out;
            transition: background 300ms ease-in-out 200ms, opacity 350ms ease-in-out 200ms, transform 400ms ease-in-out, -webkit-transform 400ms ease-in-out;
            pointer-events: none;
            content: "";
            opacity: 0;
            z-index: -999;
        }
        .toggle label::after {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 4px;
            margin: auto;
            width: 14px;
            height: 14px;
            background: #fff;
            border: 1px solid black;
            content: "";
            border-radius: 100px;
            -webkit-transition: background 200ms linear, -webkit-transform 200ms ease-in-out 100ms;
            transition: background 200ms linear, -webkit-transform 200ms ease-in-out 100ms;
            transition: background 200ms linear, transform 200ms ease-in-out 100ms;
            transition: background 200ms linear, transform 200ms ease-in-out 100ms, -webkit-transform 200ms ease-in-out 100ms;
        }

        .toggle input {
            display: none;
        }
        .toggle input:checked ~ label:after {
            background: #000;
            -webkit-transform: translate3d(27px, 0, 0);
            transform: translate3d(27px, 0, 0);
        }
        .toggle input:checked ~ label:before {
            -webkit-transform: translate3d(-84%, 23%, 0) scale(1);
            transform: translate3d(-84%, 23%, 0) scale(1);
            -webkit-transition: background 300ms ease-in-out, opacity 30ms ease-in-out, -webkit-transform 400ms ease-in-out;
            transition: background 300ms ease-in-out, opacity 30ms ease-in-out, -webkit-transform 400ms ease-in-out;
            transition: background 300ms ease-in-out, opacity 30ms ease-in-out, transform 400ms ease-in-out;
            transition: background 300ms ease-in-out, opacity 30ms ease-in-out, transform 400ms ease-in-out, -webkit-transform 400ms ease-in-out;
            opacity: 1;
        }
    </style>
</head>
<body>

<div class="browser">
    <div class="browser__header">
        <i></i>
        <i></i>
        <i></i>
    </div>

    <div class="browser__content">
        <c:forEach items="${requestScope.notices}" var="nt" varStatus="stat">
        <h1>${nt.title}</h1>
        <%--<p>jQuery是一个快速、简洁的JavaScript框架，是继Prototype之后又一个优秀的JavaScript代码库（或JavaScript框架）。jQuery设计的宗旨是“write Less，Do More”，即倡导写更少的代码，做更多的事情。它封装JavaScript常用的功能代码，提供一种简便的JavaScript设计模式，优化HTML文档操作、事件处理、动画设计和Ajax交互。</p>

        <p>jQuery的核心特性可以总结为：具有独特的链式语法和短小清晰的多功能接口；具有高效灵活的css选择器，并且可对CSS选择器进行扩展；拥有便捷的插件扩展机制和丰富的插件。jQuery兼容各种主流浏览器，如IE 6.0+、FF 1.5+、Safari 2.0+、Opera 9.0+等。</p>--%>
            <p>${nt.content}</p>
        </c:forEach>
    </div>

    <div class="toggle">
        <input type="checkbox" id="toggle">
        <label for="toggle" />
    </div>

</div>

<script>
    const toggle = document.querySelector('.toggle');
    let root = document.documentElement;

    toggle.addEventListener('change', e => {
        if (e.target.checked) {
            root.style.setProperty('--background', 'black');
            root.style.setProperty('--text', 'white');
        } else {
            root.style.setProperty('--background', 'white');
            root.style.setProperty('--text', 'black');
        }
    })</script>

</body>
</html>